// 初始化Form1
function doOnFormInit1(){
 
	if(typeof editForm1!='object') {
		$func.alert('初始化详细信息页面失败', 'red');
		return ;
	}
	/*var status = editForm1.getCombo('status');
	status.addOption(parent.statusComboData);
	status.setComboValue('');
	status.readonly(true);*/
	if(edit_type=='add'){
		editForm1.setItemValue("id",parent.rondomNum);
	}

	$(editForm1.getInput("dictCode")).attr("maxlength",50);
	$(editForm1.getInput("dictName")).attr("maxlength",50);
	$(editForm1.getInput("remark")).attr("maxlength",100);

	if(edit_type!='edit') return;
 	if (!parent.oneHosDictGroupInfo||!parent.oneHosDictGroupInfo.id) return;
	editForm1.setItemValue("id",escape2Html(parent.oneHosDictGroupInfo.id));
	editForm1.setItemValue("dictName",escape2Html(parent.oneHosDictGroupInfo.group_name));
	editForm1.setItemValue("dictCode",escape2Html(parent.oneHosDictGroupInfo.group_code));
	// editForm1.setItemValue("status",parent.oneHosDictInfo.status);
	// editForm1.setItemValue("sortNum",parent.oneHosDictInfo.sort_num);
	editForm1.setItemValue("remark",escape2Html(parent.oneHosDictGroupInfo.remark));
	editForm1.setReadonly('dictCode', true);
	// editForm1.setReadonly('groupName', true);
}
//初始化按钮form
function doOnButtonForm(){
	if (typeof(buttonForm) == "object"){
		buttonForm.attachEvent("onButtonClick", function(name, command) {
			switch(command) {
				case 'save':doSave();break;
				case 'cancle':doCancle();break;
			}
		});
	}
}

//校验新增/编辑form表单
function checkForm(){
	var dictName = $.trim(editForm1.getItemValue("dictName"));
	if(dictName.length==0){
		$func.alert('请输入字典名称', 'red');
		return false;
	}
	var dictCode = $.trim(editForm1.getItemValue("dictCode"));
	if(dictCode.length==0){
		$func.alert('请输入字典编码', 'red');
		return false;
	}
	/*var status = $.trim(editForm1.getItemValue("status"));
	if(status.length==0){
		$func.alert('请选择状态', 'red');
		return false;
	}*/
	return true;
}
//保存动作
function doSave(){
	if(!checkForm())return;
	// editForm1.removeItem("name");
	// editForm1.setItemValue("cateTypeValue",editForm1.getCombo("cateType").getComboText());
	
 	var formData = JSON.stringify(editForm1.getFormData());
 	var url=basePath+'dict/addSysDictGroup';
 	if(edit_type=='edit') url=basePath+'dict/editSysDictGroup';
	$.ajax({
        url: url,
        type: 'post',
        dataType: 'json',
        contentType:"application/json",
        data:formData,
        success: function (back) {
        	if(!back||!back.result){
        		$func.alert(back.message?back.message:'保存出错', "red");
        		return;
        	}
        	$func.alert("成功！", "green");
        	parent.doRefresh();
        	doCancle();
        }
    });
}
//取消动作
function doCancle(){
	parent.editHosDictGroupWin.close();
}
 